<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"dnxbjyj.gitee.io","root":"/blog/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","width":320,"display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"mac"},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":true},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="以下用法是在ubuntu系统下的用法，主要内容整理自廖雪峰的官方网站  安装gitsudo apt-get install git 声明git账号git config --global user.name &quot;Your Name&quot;git config --global user.email &quot;email@example.com&quot; 创建版本库（假设库名为lea">
<meta property="og:type" content="article">
<meta property="og:title" content="GitHub边用边总结">
<meta property="og:url" content="https://dnxbjyj.gitee.io/blog/posts/Tools/Git/20211026-git-daily.html">
<meta property="og:site_name" content="MindCons">
<meta property="og:description" content="以下用法是在ubuntu系统下的用法，主要内容整理自廖雪峰的官方网站  安装gitsudo apt-get install git 声明git账号git config --global user.name &quot;Your Name&quot;git config --global user.email &quot;email@example.com&quot; 创建版本库（假设库名为lea">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-10-25T16:13:47.000Z">
<meta property="article:modified_time" content="2021-10-25T16:18:03.908Z">
<meta property="article:author" content="m2fox">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://dnxbjyj.gitee.io/blog/posts/Tools/Git/20211026-git-daily.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>GitHub边用边总结 | MindCons</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">MindCons</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/blog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/blog/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://dnxbjyj.gitee.io/blog/posts/Tools/Git/20211026-git-daily.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="m2fox">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="MindCons">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          GitHub边用边总结
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-10-26 00:13:47 / 修改时间：00:18:03" itemprop="dateCreated datePublished" datetime="2021-10-26T00:13:47+08:00">2021-10-26</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Tools/" itemprop="url" rel="index"><span itemprop="name">Tools</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Tools/Git/" itemprop="url" rel="index"><span itemprop="name">Git</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <blockquote>
<p>以下用法是在ubuntu系统下的用法，主要内容整理自<a target="_blank" rel="noopener" href="https://www.liaoxuefeng.com/">廖雪峰的官方网站</a></p>
</blockquote>
<h1 id="安装git"><a href="#安装git" class="headerlink" title="安装git"></a>安装git</h1><p><code>sudo apt-get install git</code></p>
<h1 id="声明git账号"><a href="#声明git账号" class="headerlink" title="声明git账号"></a>声明git账号</h1><p><code>git config --global user.name &quot;Your Name&quot;</code><br><code>git config --global user.email &quot;email@example.com&quot;</code></p>
<h1 id="创建版本库（假设库名为learngit）"><a href="#创建版本库（假设库名为learngit）" class="headerlink" title="创建版本库（假设库名为learngit）"></a>创建版本库（假设库名为learngit）</h1><p><code>mkdir learngit</code><br><code>cd learngit</code><br><code>git init</code><br>接着创建一个文本文件readme.txt,并写入内容＂hello＂<br><code>git add readme.txt</code><br><code>git commit -m &quot;wrote a readme file&quot;</code></p>
<span id="more"></span>

<h1 id="查看git状态"><a href="#查看git状态" class="headerlink" title="查看git状态"></a>查看git状态</h1><p><code>git status</code><br><code>git diff</code>  #查看修改内容</p>
<h1 id="查看提交版本号："><a href="#查看提交版本号：" class="headerlink" title="查看提交版本号："></a>查看提交版本号：</h1><p><code>git log</code><br><code>git reflog</code>  #未来的版本<br><code>git reset --hard commit_id</code>  # 强制回退到某个版本</p>
<h1 id="撤消修改"><a href="#撤消修改" class="headerlink" title="撤消修改"></a>撤消修改</h1><p><code>git checkout -- readme.txt</code>　　＃丢弃工作区的修改<br><code>git reset HEAD readme.txt</code>  #丢弃暂存区的修改＇</p>
<h1 id="删除文件"><a href="#删除文件" class="headerlink" title="删除文件"></a>删除文件</h1><p><code>git rm test.txt</code><br><code>git commit -m &quot;remove test.txt&quot;</code></p>
<h1 id="创建SSH-Key-在用户主目录下"><a href="#创建SSH-Key-在用户主目录下" class="headerlink" title="创建SSH Key(在用户主目录下)"></a>创建SSH Key(在用户主目录下)</h1><p><code>ssh-keygen -t rsa -C &quot;dnxbjyj@126.com&quot;</code><br>在刚刚提示的目录下找到id_rsa.pub文件，用文本编辑器打开，复制里面的一长串字符；登录github,在账号设置里面找到SSH Keys页面，填入任意title,在Key文本框里复制进去刚刚复制的字符，然后点击Add Key,之后就能从本地push了。</p>
<h1 id="添加远程库"><a href="#添加远程库" class="headerlink" title="添加远程库"></a>添加远程库</h1><p>(在github建立远程库，假设建立的库名为learngit)<br><code>git remote add origin git@github.com:dnxbjyj/learngit.git</code>  #关联远程库<br><code>git push -u origin master</code>  #第一次推送master分支的所有内容<br><code>git push origin master</code>  #后面推送master的所有内容<br><code>git remote rm origin</code>  #断开和远程库的关联</p>
<h1 id="创建与合并分支"><a href="#创建与合并分支" class="headerlink" title="创建与合并分支"></a>创建与合并分支</h1><p><code>git branch</code>  #查看分支<br><code>git branch &lt;name&gt;</code>  #创建分支<br><code>git checkout &lt;name&gt;</code>  #切换到某分支<br><code>git branch -b &lt;name&gt;</code>  #创建并跳转到某分支<br><code>git merge &lt;name&gt;</code>  #合并某分支到当前分支<br><code>git branch -d &lt;name&gt;</code> 　#删除某分支<br><code>git branch -D &lt;name&gt;</code>    #强制删除没有合并完全的分支</p>
<h1 id="推送分支"><a href="#推送分支" class="headerlink" title="推送分支"></a>推送分支</h1><p><code>git remote</code>  #查看远程库的信息<br><code>git remote -v</code>  #查看远程库的详细信息，显示可以抓取和推送的origin的地址<br><code>git push origin master</code>  #向远程的origin推送本地的master分支</p>
<h1 id="抓取分支"><a href="#抓取分支" class="headerlink" title="抓取分支"></a>抓取分支</h1><p><code>git checkout -b dev origin/dev</code>  #创建远程origin的dev分支到本地<br><code>git branch --set-upstream-to = origin/dev</code>  #指定本地dev分支与远程origin/dev分支的链接<br><code>git pull</code>  #把最新提交从origin/dev上抓取下来<br>(再合并分支，若出现冲突，则解决冲突,再add,commit)<br><code>git push origin dev</code>  #push dev分支</p>
<h1 id="把最新的分支从origin-goods上抓取下来到当前本地分支："><a href="#把最新的分支从origin-goods上抓取下来到当前本地分支：" class="headerlink" title="把最新的分支从origin/goods上抓取下来到当前本地分支："></a>把最新的分支从origin/goods上抓取下来到当前本地分支：</h1><p><code>git pull origin goods</code></p>
<h1 id="git-clone远程仓库的某个分支到本地："><a href="#git-clone远程仓库的某个分支到本地：" class="headerlink" title="git clone远程仓库的某个分支到本地："></a>git clone远程仓库的某个分支到本地：</h1><p><code>git clone -b goods git@github.com:senguo2014/senguo.cc.git</code>　　＃clone远程的goods分支</p>
<h1 id="完整流程"><a href="#完整流程" class="headerlink" title="完整流程"></a>完整流程</h1><h3 id="拉远程库最新的代码到本地分支："><a href="#拉远程库最新的代码到本地分支：" class="headerlink" title="拉远程库最新的代码到本地分支："></a>拉远程库最新的代码到本地分支：</h3><p><code>git fetch origin test:tmp</code> #将远程库上origin目录下的test分支拉到本地库并在本地库创建tmp分支<br>或：<br><code>git pull origin test</code>　　＃将远程库上origin下的test分支拉到本地当前分支上（会自动merge）</p>
<h3 id="切换到本地的working分支："><a href="#切换到本地的working分支：" class="headerlink" title="切换到本地的working分支："></a>切换到本地的working分支：</h3><p><code>git checkout working</code><br><code>git branch</code>  #查看当前分支</p>
<h3 id="写代码，修改代码．然后提交所有修改："><a href="#写代码，修改代码．然后提交所有修改：" class="headerlink" title="写代码，修改代码．然后提交所有修改："></a>写代码，修改代码．然后提交所有修改：</h3><p><code>gti status</code>  #查看当前分支状态<br><code>git add .</code>　＃注：最后是一个点<br><code>git commit -a -m &quot;hello&quot;</code></p>
<h3 id="将本地的tmp分支合并到当前的working分支："><a href="#将本地的tmp分支合并到当前的working分支：" class="headerlink" title="将本地的tmp分支合并到当前的working分支："></a>将本地的tmp分支合并到当前的working分支：</h3><p><code>git merge tmp</code></p>
<h3 id="根据提示，打开代码文件逐一修改冲突"><a href="#根据提示，打开代码文件逐一修改冲突" class="headerlink" title="根据提示，打开代码文件逐一修改冲突"></a>根据提示，打开代码文件逐一修改冲突</h3><p><code>HEAD&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;内容１=======内容２&gt;&gt;&gt;&gt;&gt;&gt;&gt;working</code></p>
<h3 id="冲突修改完以后，再merge一遍，然后将当前分支的内容提交到远程库的test分支上："><a href="#冲突修改完以后，再merge一遍，然后将当前分支的内容提交到远程库的test分支上：" class="headerlink" title="冲突修改完以后，再merge一遍，然后将当前分支的内容提交到远程库的test分支上："></a>冲突修改完以后，再merge一遍，然后将当前分支的内容提交到远程库的test分支上：</h3><p><code>git push origin test</code></p>
<h3 id="总结：可以简略地归结为三步曲："><a href="#总结：可以简略地归结为三步曲：" class="headerlink" title="总结：可以简略地归结为三步曲："></a>总结：可以简略地归结为三步曲：</h3><p><code>git fetch origin master:tmp</code>  #将远程的master分支fetch到本地的tmp分支上,若tmp分支不存在,则自动新建.<br><code>git diff tmp</code><br><code>git merge tmp</code>  #将当前分支和tmp分支merge<br><code>git push origin master:newbranch</code>  #其中master表示本地master,newbranch表示在远程创建的新分支或远程已经有的分支.</p>
<h1 id="删除远程test分支："><a href="#删除远程test分支：" class="headerlink" title="删除远程test分支："></a>删除远程test分支：</h1><p><code>git push origin --delete test</code></p>
<h1 id="推送分支-1"><a href="#推送分支-1" class="headerlink" title="推送分支"></a>推送分支</h1><p><code>git push &lt;远程主机名(origin)&gt; &lt;本地分支名&gt;:&lt;远程分支名&gt;</code><br> 注意，分支推送顺序的写法是<code>&lt;来源地&gt;:&lt;目的地&gt;</code>，所以git pull是<code>&lt;远程分支&gt;:&lt;本地分支&gt;</code>，而git push是<code>&lt;本地分支&gt;:&lt;远程分支&gt;</code>。<br>如果省略远程分支名，则表示将本地分支推送与之存在”追踪关系”的远程分支(通常两者同名)，如果该远程分支不存在，则会被新建。</p>
<h1 id="git的-gitignore不起作用的原因"><a href="#git的-gitignore不起作用的原因" class="headerlink" title="git的.gitignore不起作用的原因"></a>git的.gitignore不起作用的原因</h1><p>可能为：先添加到本地分支其他文件再添加的.gitignore文件<br>解决方法：先清空本地分支，然后先添加和提交.gitignore文件到本地分支，然后再添加提交其他文件到本地分支，然后再往远程分支推．</p>
<h1 id="文件权限问题"><a href="#文件权限问题" class="headerlink" title="文件权限问题"></a>文件权限问题</h1><p>git上fetch下来的文件的默认权限是100644，在这种权限下在本地是无法对代码进行修改的，需要<code>chmod -R 777 workgit</code>，然后对代码进行修改．在向远程push代码的时候，还要先把权限改回100644，这样才不会起冲突(这种修改权限的方法可能会失效,所以最好的解决方法就是不要修改权限,而用sudo权限打开sublime然后再编辑代码)．</p>
<h1 id="在新建库后pull或clone的时候出现错误："><a href="#在新建库后pull或clone的时候出现错误：" class="headerlink" title="在新建库后pull或clone的时候出现错误："></a>在新建库后pull或clone的时候出现错误：</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Permission denied (publickey).</span><br><span class="line">fatal: Could not read from remote repository.</span><br><span class="line"></span><br><span class="line">Please make sure you have the correct access rights</span><br><span class="line">and the repository exists.</span><br></pre></td></tr></table></figure>

<p>可能的解决的方法：<br>１．<code>ssh-keygen...</code>命令前加sudo，然后再按原来的步骤来做．</p>
<h1 id="公钥只与电脑有关-与是否新建仓库无关"><a href="#公钥只与电脑有关-与是否新建仓库无关" class="headerlink" title="公钥只与电脑有关,与是否新建仓库无关"></a>公钥只与电脑有关,与是否新建仓库无关</h1><h1 id="查看历史版本"><a href="#查看历史版本" class="headerlink" title="查看历史版本"></a>查看历史版本</h1><p><code>git log</code></p>
<h1 id="删除子模块"><a href="#删除子模块" class="headerlink" title="删除子模块"></a>删除子模块</h1><p>rm -rf 子模块目录 删除子模块目录及源码<br>vi .gitmodules 删除项目目录下.gitmodules文件中子模块相关条目<br>vi .git/config 删除配置项中子模块相关条目<br>rm .git/module/* 删除模块下的子模块目录，每个子模块对应一个目录，注意只删除对应的子模块目录即可<br>执行完成后，再执行添加子模块命令即可，如果仍然报错，执行如下：</p>
<p>git rm –cached 子模块名称</p>
<p>完成删除后，提交到仓库即可。</p>

    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>m2fox
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://dnxbjyj.gitee.io/blog/posts/Tools/Git/20211026-git-daily.html" title="GitHub边用边总结">https://dnxbjyj.gitee.io/blog/posts/Tools/Git/20211026-git-daily.html</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-Hans" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/posts/Blog-Meta/20211023-blog-map.html" rel="prev" title="博客分类地图">
      <i class="fa fa-chevron-left"></i> 博客分类地图
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/posts/%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE%E7%AC%94%E8%AE%B0/%E6%8A%80%E6%9C%AF/20211107-install-kali-based-on-wsl2.html" rel="next" title="基于wsl2的kali桌面系统的安装和配置">
      基于wsl2的kali桌面系统的安装和配置 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%AE%89%E8%A3%85git"><span class="nav-number">1.</span> <span class="nav-text">安装git</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%A3%B0%E6%98%8Egit%E8%B4%A6%E5%8F%B7"><span class="nav-number">2.</span> <span class="nav-text">声明git账号</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E7%89%88%E6%9C%AC%E5%BA%93%EF%BC%88%E5%81%87%E8%AE%BE%E5%BA%93%E5%90%8D%E4%B8%BAlearngit%EF%BC%89"><span class="nav-number">3.</span> <span class="nav-text">创建版本库（假设库名为learngit）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8Bgit%E7%8A%B6%E6%80%81"><span class="nav-number">4.</span> <span class="nav-text">查看git状态</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E7%89%88%E6%9C%AC%E5%8F%B7%EF%BC%9A"><span class="nav-number">5.</span> <span class="nav-text">查看提交版本号：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%92%A4%E6%B6%88%E4%BF%AE%E6%94%B9"><span class="nav-number">6.</span> <span class="nav-text">撤消修改</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6"><span class="nav-number">7.</span> <span class="nav-text">删除文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%9B%E5%BB%BASSH-Key-%E5%9C%A8%E7%94%A8%E6%88%B7%E4%B8%BB%E7%9B%AE%E5%BD%95%E4%B8%8B"><span class="nav-number">8.</span> <span class="nav-text">创建SSH Key(在用户主目录下)</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%B7%BB%E5%8A%A0%E8%BF%9C%E7%A8%8B%E5%BA%93"><span class="nav-number">9.</span> <span class="nav-text">添加远程库</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E4%B8%8E%E5%90%88%E5%B9%B6%E5%88%86%E6%94%AF"><span class="nav-number">10.</span> <span class="nav-text">创建与合并分支</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8E%A8%E9%80%81%E5%88%86%E6%94%AF"><span class="nav-number">11.</span> <span class="nav-text">推送分支</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8A%93%E5%8F%96%E5%88%86%E6%94%AF"><span class="nav-number">12.</span> <span class="nav-text">抓取分支</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8A%8A%E6%9C%80%E6%96%B0%E7%9A%84%E5%88%86%E6%94%AF%E4%BB%8Eorigin-goods%E4%B8%8A%E6%8A%93%E5%8F%96%E4%B8%8B%E6%9D%A5%E5%88%B0%E5%BD%93%E5%89%8D%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%EF%BC%9A"><span class="nav-number">13.</span> <span class="nav-text">把最新的分支从origin&#x2F;goods上抓取下来到当前本地分支：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git-clone%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%9F%90%E4%B8%AA%E5%88%86%E6%94%AF%E5%88%B0%E6%9C%AC%E5%9C%B0%EF%BC%9A"><span class="nav-number">14.</span> <span class="nav-text">git clone远程仓库的某个分支到本地：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B"><span class="nav-number">15.</span> <span class="nav-text">完整流程</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8B%89%E8%BF%9C%E7%A8%8B%E5%BA%93%E6%9C%80%E6%96%B0%E7%9A%84%E4%BB%A3%E7%A0%81%E5%88%B0%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%EF%BC%9A"><span class="nav-number">15.0.1.</span> <span class="nav-text">拉远程库最新的代码到本地分支：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%87%E6%8D%A2%E5%88%B0%E6%9C%AC%E5%9C%B0%E7%9A%84working%E5%88%86%E6%94%AF%EF%BC%9A"><span class="nav-number">15.0.2.</span> <span class="nav-text">切换到本地的working分支：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%86%99%E4%BB%A3%E7%A0%81%EF%BC%8C%E4%BF%AE%E6%94%B9%E4%BB%A3%E7%A0%81%EF%BC%8E%E7%84%B6%E5%90%8E%E6%8F%90%E4%BA%A4%E6%89%80%E6%9C%89%E4%BF%AE%E6%94%B9%EF%BC%9A"><span class="nav-number">15.0.3.</span> <span class="nav-text">写代码，修改代码．然后提交所有修改：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B0%86%E6%9C%AC%E5%9C%B0%E7%9A%84tmp%E5%88%86%E6%94%AF%E5%90%88%E5%B9%B6%E5%88%B0%E5%BD%93%E5%89%8D%E7%9A%84working%E5%88%86%E6%94%AF%EF%BC%9A"><span class="nav-number">15.0.4.</span> <span class="nav-text">将本地的tmp分支合并到当前的working分支：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%B9%E6%8D%AE%E6%8F%90%E7%A4%BA%EF%BC%8C%E6%89%93%E5%BC%80%E4%BB%A3%E7%A0%81%E6%96%87%E4%BB%B6%E9%80%90%E4%B8%80%E4%BF%AE%E6%94%B9%E5%86%B2%E7%AA%81"><span class="nav-number">15.0.5.</span> <span class="nav-text">根据提示，打开代码文件逐一修改冲突</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%86%B2%E7%AA%81%E4%BF%AE%E6%94%B9%E5%AE%8C%E4%BB%A5%E5%90%8E%EF%BC%8C%E5%86%8Dmerge%E4%B8%80%E9%81%8D%EF%BC%8C%E7%84%B6%E5%90%8E%E5%B0%86%E5%BD%93%E5%89%8D%E5%88%86%E6%94%AF%E7%9A%84%E5%86%85%E5%AE%B9%E6%8F%90%E4%BA%A4%E5%88%B0%E8%BF%9C%E7%A8%8B%E5%BA%93%E7%9A%84test%E5%88%86%E6%94%AF%E4%B8%8A%EF%BC%9A"><span class="nav-number">15.0.6.</span> <span class="nav-text">冲突修改完以后，再merge一遍，然后将当前分支的内容提交到远程库的test分支上：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%80%BB%E7%BB%93%EF%BC%9A%E5%8F%AF%E4%BB%A5%E7%AE%80%E7%95%A5%E5%9C%B0%E5%BD%92%E7%BB%93%E4%B8%BA%E4%B8%89%E6%AD%A5%E6%9B%B2%EF%BC%9A"><span class="nav-number">15.0.7.</span> <span class="nav-text">总结：可以简略地归结为三步曲：</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8Btest%E5%88%86%E6%94%AF%EF%BC%9A"><span class="nav-number">16.</span> <span class="nav-text">删除远程test分支：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8E%A8%E9%80%81%E5%88%86%E6%94%AF-1"><span class="nav-number">17.</span> <span class="nav-text">推送分支</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#git%E7%9A%84-gitignore%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%E7%9A%84%E5%8E%9F%E5%9B%A0"><span class="nav-number">18.</span> <span class="nav-text">git的.gitignore不起作用的原因</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E6%9D%83%E9%99%90%E9%97%AE%E9%A2%98"><span class="nav-number">19.</span> <span class="nav-text">文件权限问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9C%A8%E6%96%B0%E5%BB%BA%E5%BA%93%E5%90%8Epull%E6%88%96clone%E7%9A%84%E6%97%B6%E5%80%99%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF%EF%BC%9A"><span class="nav-number">20.</span> <span class="nav-text">在新建库后pull或clone的时候出现错误：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AC%E9%92%A5%E5%8F%AA%E4%B8%8E%E7%94%B5%E8%84%91%E6%9C%89%E5%85%B3-%E4%B8%8E%E6%98%AF%E5%90%A6%E6%96%B0%E5%BB%BA%E4%BB%93%E5%BA%93%E6%97%A0%E5%85%B3"><span class="nav-number">21.</span> <span class="nav-text">公钥只与电脑有关,与是否新建仓库无关</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%9F%A5%E7%9C%8B%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC"><span class="nav-number">22.</span> <span class="nav-text">查看历史版本</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%88%A0%E9%99%A4%E5%AD%90%E6%A8%A1%E5%9D%97"><span class="nav-number">23.</span> <span class="nav-text">删除子模块</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">m2fox</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">12</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/blog/categories/">
          
        <span class="site-state-item-count">12</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-Hans" class="cc-opacity" rel="noopener" target="_blank"><img src="/blog/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">m2fox</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  




  
<script src="/blog/js/local-search.js"></script>













  

  

</body>
</html>
